package aufgabe_2_test.try02;

import java.io.Serializable;
import java.math.BigInteger;

public class RhoMessage implements Serializable{
	private static final long serialVersionUID = 6965802132441637440L;
	/**
	 * represent the N in Rho method
	 */
	private BigInteger n;
	/**
	 * found factor
	 */
	private boolean factorFound;
	/**
	 * kind of message
	 */
	MsgType mt;
	/**
	 * used cpu-time in pollard thread
	 */
	long cpuTime;
	
	RhoMessage(BigInteger n, MsgType m,boolean found, long cpuTime){
		this.n = n;
		this.mt = m;
		this.factorFound = found;
		this.cpuTime = cpuTime;
	}
	
	RhoMessage(BigInteger n, MsgType m,boolean found){
		this(n, m, found, 0);
	}
	
	public long getCpuTime() {
		return cpuTime;
	}
	
	public BigInteger getN() {
		return n;
	}

	public boolean getFound(){
		return factorFound;
	}
	
	/**
	 * will be used in onReceive-method of akka actors
	 * define the usage of a message
	 */
	public enum MsgType{
		RhoResult,RhoFoundPrime,RhoRequestWorker,RhoGoSleep,RhoTest,RhoCanceled,RhoGetStatus;
	}
	
	public String toString(){
		return mt.name()+" "+ factorFound+" "+n;
	}
}
